package com.bdjk.bdmw.InfoGath.communication.protocol.littleNurse;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.bdjk.bdmw.InfoGath.business.nurse.vo.NursePositionVO;
import com.bdjk.bdmw.InfoGath.communication.protocol.BaseProtocol;

public class NurseLBSProtocol extends BaseProtocol<NursePositionVO> {

	public NurseLBSProtocol(){
		this.isResponse=false;
		this.isSave=true;
	}
	@Override
	public String encodeMessage(NursePositionVO model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public NursePositionVO decodeMessage(String message) {
		// TODO Auto-generated method stub
		NursePositionVO vo = new NursePositionVO();
	    String[] params = message.split(",");
	    vo.setProVersion(params[0]);
	    vo.setMesId(params[1]);
	    vo.setEncryptType(params[2]);
	    vo.setValidatCode(params[3]);
	    vo.setSendTime(params[4]);
	    vo.setTerType(params[5]);
	    vo.setTerIdent(params[6]);
	    vo.setTimeZone(params[7]);
	    vo.setMesType(params[8]);
	    
	    vo.setDataType(params[9]);
	    StringBuffer sb = new StringBuffer();
	    sb.append("count$0$");
	    sb.append(params[10].substring(3) + "|");
	    sb.append(params[11] + "|");
	    sb.append(params[12]);
	    vo.setBaseInfo(sb.toString());
	    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	    Date date = new Date(Long.valueOf(params[13]).longValue());
	    vo.setCollectMills(format.format(date));
	    this.terIdent = vo.getTerIdent();
	    return vo;
	}
	

}
